//
//  NotificationViewController.swift
//  MacStudy
//
//  Created by 30san on 2022/9/30.
//  Copyright © 2022 Dawninest. All rights reserved.
//

import Cocoa
//import UserNotifications

class NotificationViewController: NSViewController {
    
//    private var noti: NSUserNotification?

    override func viewDidLoad() {
        super.viewDidLoad()
        title = "\(self.className)"
        
        NSUserNotificationCenter.default.delegate = self
        
    }
    
    @IBAction func push(_ sender: Any) {
        let noti = NSUserNotification()
        noti.title = "这是一个标题"
        noti.informativeText = "这是消息推送内容"
        noti.hasReplyButton = true
        noti.contentImage = NSImage.init(named: "1")
        noti.otherButtonTitle = "取消"
        noti.responsePlaceholder = "快速回复"
        NSUserNotificationCenter.default.deliver(noti)
        print("push")
    }
}


extension NotificationViewController: NSUserNotificationCenterDelegate {
    func userNotificationCenter(_ center: NSUserNotificationCenter, didDeliver notification: NSUserNotification) {
        
    }
    
    func userNotificationCenter(_ center: NSUserNotificationCenter, didActivate notification: NSUserNotification) {
        
    }
    
    func userNotificationCenter(_ center: NSUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool {
        return true
    }
}
